function s(){
    //页面初次渲染的时候
    let tr = document.querySelectorAll('.tr');

    let all = document.querySelector('#all');
    let allnum = 0 ;


    for(let  i = 0; i< tr.length; i++){
        //单价
        var price = tr[i].children[2].innerHTML;
        //数量
        var num = tr[i].children[3].children[0].value;
        //小计
        var total = tr[i].children[4].children[0].innerHTML = price * num;

        //console.log(total);
        allnum += total
    }

    console.log(allnum);
    all.innerHTML = allnum.toFixed(2);

}
s();

let  num_all = document.querySelectorAll('#table .num');

for(let p = 0; p <num_all.length; p++){
    num_all[p].addEventListener('change',s)
}

let del_all = document.querySelectorAll('#table .del');
for(let k = 0; k <del_all.length; k++){
    del_all[k].addEventListener('click',function(){
        console.log(this.parentNode.parentNode.parentNode);
        console.log(this.parentNode.parentNode);
        this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode)

        s()
    })
}



